package tax.szz.mini.core.proxy;

import tax.szz.mini.core.core.BaseEsMapper;
import tax.szz.mini.core.core.BaseEsMapperImpl;

import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 作者：沈自在 <a href="https://www.szz.tax">Blog</a>
 *
 * @description Mapper 的代理
 * @date 2023/12/15
 */
public class EsMapperProxy<T> implements InvocationHandler, Serializable {

    private final Class<T> mapperInterface;

    public EsMapperProxy(Class<T> mapperInterface) {
        this.mapperInterface = mapperInterface;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        BaseEsMapper<?> baseEsMapper = new BaseEsMapperImpl<>();
        return method.invoke(baseEsMapper, args);
    }
}
